package com.damai.controller.entities;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import com.citywithincity.db.meta.ColumnStruct;
import com.damai.meta.MetaData;

public class TableStructVo extends MetaData implements Comparator<ColumnStruct> {
	
	
	private String pk;
	
	private List<ColumnStruct> columns;

	public String getPk() {
		return pk;
	}

	public void setPk(String pk) {
		this.pk = pk;
	}

	public Collection<ColumnStruct> getColumns() {
		return columns;
	}

	public void setColumns(Collection<ColumnStruct> columns) {
		this.columns = new ArrayList<ColumnStruct>();
		this.columns.addAll(columns);
		Collections.sort(this.columns, this);
	}

	
	@Override
	public int compare(ColumnStruct o1, ColumnStruct o2) {
		return o2.getIndex() > o1.getIndex() ? 0 : 1;
	}
}
